<template>
	<div class="compile_page" style="height:100vh">
		<div class="header">
        <van-nav-bar
              title="个人信息"
              left-arrow
              @click-left="onClickLeft"
              right-arrow
              right-text="修改"
              @click-right="onclickRight"
        />
		</div>

		<div class="compile_con" style="padding-top:2vh;">

            <van-cell-group >
                <van-field
                    label="省/直辖市"
                    placeholder=""
                    readonly
                    v-model="p_name"
                    style="font-size:0.9rem;"
                />
              <van-field
                label="市"
                placeholder=""
                readonly
                v-model="c_name"
                style="font-size:0.9rem;"
              />
              <van-field
                label="区县"
                placeholder=""
                readonly
                v-model="a_name"
                style="font-size:0.9rem;"
              />
              <van-field
                label="乡镇"
                placeholder=""
                readonly
                v-model="s_name"
                style="font-size:0.9rem;"
              />
              <van-field
                label="村"
                placeholder=""
                readonly
                v-model="v_name"
                style="font-size:0.9rem;"
              />
            </van-cell-group>

		</div>
	</div>
</template>
<script>
	export default {
	    data() {
	        return {
            user:'',
              p_name:'',
              c_name:'',
              a_name:'',
              s_name:'',
              v_name:''

	        };
        },
        mounted:function(){
            const that = this;
            let local_user = localStorage.getItem("user");
            if (local_user != undefined && local_user != "undefined") {
                let user = JSON.parse(local_user);
                that.user = user;
                that.user_location();
            }
        },
        methods:{
            onClickLeft(){
                this.$router.back(-1);
            },
            onclickRight(){
                if(this.user.realAuthState =='2.1' || this.user.realAuthState =='2.2'){
                    this.$toast("您已认证不允许修改");
                    return false;
                }
                this.$router.push({
                    path: '/choosecapital'
                })
            },
            user_location() {
                const that = this;
                that.$sendRequest("/v2/user_location", "userId=" + that.user.userId)
                    .then(function(res) {
                        console.log(res);
                        if (res.data.code == 0) {
                            that.p_name=res.data.result.user_location.p_name;
                            that.c_name=res.data.result.user_location.c_name;
                            that.a_name=res.data.result.user_location.a_name;
                            that.s_name=res.data.result.user_location.s_name;
                            that.v_name=res.data.result.user_location.v_name;

                        }
                    });
            },
        }
   };
</script>
<style scoped="scoped">
	p{
		margin: 0;
		padding: 0;
    }

	.compile_page >>> .van-cell__title{
		text-align: left;
		padding-left: 3vh;
	}
	.compile_page>>>.van-collapse-item__content{
		text-align: left;
		padding-left: 5.4vh;
	}
	.back_content_page{
		background: rgb(245,245,245);
	}
	.header >>> .van-icon-arrow-left{
        color: #2c3e50;
    }
	.van-hairline--top-bottom::after{
		border: none;
    }
    button{
        width: 100vw;
        height: 48px;
        background-color: rgb(76,159,253);
        border: 0;
        color: #ffffff;
        font-size: 1rem;
        position:fixed;
        bottom: 0;
        left: 0;
    }
</style>
